package sui.utils
{

    public class StringUtil
    {
        public static function trim(char:String):String
        {
            if (char == null)
            {
                return null;
            }
            return rtrim(ltrim(char));
        }

        public static function ltrim(char:String):String
        {
            if (char == null)
            {
                return null;
            }
            var pattern:RegExp = /^\s*/;
            return char.replace(pattern, "");
        }

        public static function rtrim(char:String):String
        {
            if (char == null)
            {
                return null;
            }
            var pattern:RegExp = /\s*$/;
            return char.replace(pattern, "");
        }

        public static function beginsWith(str:String, sub:String):Boolean
        {
            return (sub == str.substring(0, sub.length));
        }

        public static function endsWith(str:String, substr:String):Boolean
        {
            return (substr == str.substring(str.length - substr.length));
        }
    }
}
